<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
    <title>员工面板</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    <script src="../../scripts/boot.js" type="text/javascript"></script>


    <style type="text/css">
        html,
        body {
            padding: 0;
            margin: 0;
            border: 0;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>

<body>
    <form id="form1" method="post">
        <fieldset style="border:solid 1px #aaa;padding:3px;">
            <div style="padding:5px;">
                <table>
                    <tr>
                        <td style="width:80px;">图书名称</td>
                        <td style="width:150px;">
                            <input name="bookname" class="mini-textbox" readonly="true" />
                        </td>
                        <td style="width:80px;">出版社：</td>
                        <td>
                            <input name="publisher" class="mini-textbox" required="true" emptyText="请输入出版社" />
                        </td>

                    </tr>
                    <tr>
                        <td>作者：</td>
                        <td>
                            <input name="author" readonly="true" class="mini-textbox" />
                        </td>
                        <td>图书类别：</td>
                        <td>
                            <input name="booktype" class="mini-combobox" url="../../data/book.txt" showNullItem="true"
                                nullItemText="-请选择类别-" allowInput="true" />
                        </td>
                    </tr>
                    <tr>
                        <td>剩余数量：</td>
                        <td>
                            <input name="remain" class="mini-spinner" readonly="true" minvalue="0" maxvalue="200"
                                increment=1 format="#,0" />
                        </td>
                        <td style="width:80px;">图书编号</td>
                        <td style="width:150px;">
                            <input name="bookid" class="mini-textbox" readonly="true" emptyText="图书编号不可修改" />
                        </td>
                    </tr>
                </table>
            </div>
        </fieldset>
        <div style="text-align:center;padding:10px;">
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
        </div>
    </form>
    <script type="text/javascript">
        mini.parse();
        var form = new mini.Form("form1");
        var id;
        function SaveData() {
            var o = form.getData();

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode(o);
            $.ajax({
                url: "../../bookinfoeditaction?method=editbookinfo",
                type: 'post',
                data: { data: json },
                cache: false,
                success: function (text) {
                    var o = mini.decode(text);
                    mini.confirm('确认修改吗', "修改图书",
                        function (action) {
                            CloseWindow("save");
                        }
                    );
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }

        function SetData(data) {

            //跨页面传递的数据对象，克隆后才可以安全使用
            data = mini.clone(data);
            $.ajax({
                url: "../../bookinfodetailaction?method=querybookinfobyid&id=" + data.bookId,
                cache: false,
                success: function (text) {
                    id = data.bookId;
                    var o = mini.decode(text);
                    form.setData(o.data);
                    form.setChanged(false);//设置当前表单未修改状态
                }
            });
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) {
                return window.CloseOwnerWindow(action);
            } else {
                window.close();
            }
        }
        function onOk(e) {
            SaveData();
        }
        //取消修改
        function onCancel(e) {
            if (form.isChanged()) {
                mini.confirm("数据被修改了，是否先保存？", "提醒", function (action) {
                    if (action == 'ok') {
                        SaveData();
                    } else {
                        CloseWindow("cancel");
                    }
                })
            } else {
                CloseWindow("cancel");
            }
        }



    </script>
</body>

</html>